package org.itew.mymapreduce.core.impl;

import java.util.Collection;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import org.itew.mymapreduce.core.DataCollection;

public class SortedDataCollection<K,V> implements DataCollection<K, V>{
	
	private final Map<K,Collection<V>> map;
	
	public SortedDataCollection() {
		map = new TreeMap<K,Collection<V>>();
	}
	
	public void collect(K key,V value){
		if(!map.containsKey(key)){
			map.put(key, new LinkedList<V>());
		}
		map.get(key).add(value);
	}
	
	public Set<K> keySet(){
		return map.keySet();
	}
	
	public Collection<V> getValues(K key){
		return map.get(key);
	}

}
